import React, { Component } from 'react'
import store from "./store"
import {connect} from "react-redux"
 class App extends Component {
  render() {
    
    return (
      <div>
        <button onClick={this.props.sub}>-</button>
        {this.props.num}
        <button onClick={this.props.add}>+</button>
      </div>
    )
  }
}
const mapStateToProps=(state)=>{
  return {
    num:state.num
  }
}
const mapDispatchToProps=(dispatch)=>{
  return {
    add:function(){
      dispatch({
        type:"ADD",
        payload:{
          step:1
        }
      })
    },
    sub:function(){
      dispatch({
        type:"ADD",
        payload:{
          step:-1
        }
      })
    }
  }
}
export default connect(mapStateToProps,mapDispatchToProps)(App)